package com.sun.java.rmi;

import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.rmi.server.UnicastRemoteObject;

/**
 * This class creates an instance of the remote object implementation, exports 
 * the remote object, and then binds that instance to a name in a Java RMI registry.
 * @author prabhat.totoo
 */
public class Register {

    public static void main(String args[]) {

        try {
            ServerImpl obj = new ServerImpl();
            
            Server stub = (Server) UnicastRemoteObject.exportObject(obj, 0);

            // Bind the remote object's stub in the registry
            Registry registry = LocateRegistry.getRegistry();
            registry.bind("Hello", stub);

            System.err.println("Server ready");
        } catch (Exception e) {
            System.err.println("Server exception: " + e.toString());
            e.printStackTrace();
        }
    }
}
